import * as Utils from 'utils.js';
/**速云报表api**/
/**
 *连接设置
 */
export function settingUrl(arr, callBack) {
	let url = Utils.getPostIp("/api/Login_ShopList");
	let data = arr;
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
  
/**
 * @param {Object} GoodImagePath采购类查供应商的接口
 */
export function GetClientPurMessage(arr,callBack) {
	let url = Utils.getPostIp("/api/Get_ClientMessage");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data,state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//查询商品库存
export function Select_StockNum(arr, callBack) {
	let url = Utils.getPostIp("/api/Select_StockNum");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	}); 
}
/**
 * @param {Object}查询采购入库单
 */
export  function Select_Bill_Master(arr,callBack){
	let url = Utils.getPostIp("/api/Select_Bill_Master");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}引用上传单据查询  --------商品明细-------配出出库单 配送退回单
 */
export  function Check_ZP_Select_Bill_Detail(arr,callBack){
	let url = Utils.getPostIp("/api/Check_ZP_Select_Bill_Detail");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//价格跟踪
export function XH_Get_PriceFollowMessage(arr, callBack) {
 let url = Utils.getPostIp("/api/XH_Get_PriceFollowMessage");
 var responseArr = {};
 let data = Utils.getData(arr);
 Utils.httpGetClient(url, data, "GET", function(data, state) {
  responseArr.data = data.data;
  responseArr.state = state;
  callBack(responseArr);
 });
}
//单据审核
export function Bill_Check(arr,callBack) {
	let url = Utils.getPostIp("/api/Bill_Check");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//查询银行账户
export function Get_BankMessage(arr,callBack){
	let url = Utils.getPostIp("/api/Get_BankMessage");
	var responseArr =  {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url,data,"GET",function(data,state){
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//保存条码规则
export function Save_BarcodeRule(arr,callBack){
	let url = Utils.getPostIp("/api/Save_BarcodeRule");
	var responseArr =  {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url,data,"POST",function(data,state){
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//查询条码规则
export function Select_BarcodeRule(arr,callBack){
	let url = Utils.getPostIp("/api/Select_BarcodeRule");
	var responseArr =  {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url,data,"GET",function(data,state){
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object} GoodImagePath查询业务员
 */
export function GetOperatorMessage(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_OperatorMessage");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object} GoodImagePath查询仓库档案
 */
export function GetStoreMessage(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Bill_StoreMessage");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

//保存单据
export function Add_Bill(arr,callBack){
	let url = Utils.getPostIp("/api/Add_Bill");
	var responseArr =  {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url,data,"POST",function(data,state){
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}修改
 */
export  function Change_Bill(arr,callBack){
	let url = Utils.getPostIp("/api/Change_Bill");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"POST",function(data,state){
		
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}引用上传单据查询 ---明细 -----采购订单
 */
export  function Check_Select_Bill_Order_Detail(arr,callBack){
	let url = Utils.getPostIp("/api/Check_Select_Bill_Order_Detail");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	}); 
}
/**
 * @param {Object}删除单据
 */

export  function Delete_Bill(arr,callBack){
	let url = Utils.getPostIp("/api/Delete_Bill");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"POST",function(data,state){
		
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//获取单号
export function NewOrderNo(arr,callBack){
	let url = Utils.getPostIp("/api/NewOrderNo");
	var responseArr =  {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url,data,"POST",function(data,state){
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}引用上传单据查询 ---明细 -----采购入库单
 */
export  function Check_Select_Bill_Detail(arr,callBack){
	let url = Utils.getPostIp("/api/Check_Select_Bill_Detail");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}引用上传单据查询-----采购入库单
 */
export  function Check_Select_Bill_Master(arr,callBack){
	let url = Utils.getPostIp("/api/Check_Select_Bill_Master");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	}); 
}
/**
 * @param {Object}引用上传单据查询-----采购订单
 */
export  function Check_Select_Bill_Order_Master(arr,callBack){
	let url = Utils.getPostIp("/api/Check_Select_Bill_Order_Master");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
 
/**
 * @param {Object}查看条目明细
 */
export  function Select_Bill_Detail(arr,callBack){
	let url = Utils.getPostIp("/api/Select_Bill_Detail");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 *条码扫描商品
 */
export function GetBarcodeGoodsMessageModel(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_BarcodeGoodsMessage");
	var responseArr = {};
	let data = Utils.getData(arr);
	
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//获取全部商品
export function Get_GoodsMessage(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_GoodsMessage");
	var responseArr = {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url,data,"GET",function(data,state){
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//远程打印
export function Add_Android_Print(arr, callBack) {
	let url = Utils.getPostIp("/api/Add_Android_Print");
	var responseArr = {}; 
	let data = Utils.getData(arr);
	Utils.httpGetClient(url,data,"POST",function(data,state){
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}引用上传单据查询  -----配出出库单 配送退回单
 */
export  function Check_ZP_Select_Bill_Master(arr,callBack){
	let url = Utils.getPostIp("/api/Check_ZP_Select_Bill_Master");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//图片路径处理
export function setImageUrl(GoodImagePath) {
	//ip
	var ip = uni.getStorageSync("ip");
	//端口
	var ipPost = uni.getStorageSync("ipPost");

	if (GoodImagePath == "") {
		return '/static/default1.jpg';
	} else {
		let path = "http://" + ip;
		if (ipPost != "") {
			path += ":" + ipPost;
		}
		console.log(path + "/picture" + GoodImagePath);
		return path + "/picture" + GoodImagePath;
	}
}
//提示框无图标
export function showTip(msg) {
	uni.showToast({
		position: 'center',
		title: msg,
		duration: 1000,
		style: "z-index:9999",
		icon:'none'
	});
};
//叹号提示
export function WarningTip(msg) {
	uni.showToast({
		position: 'bottom',
		title: msg,
		icon:'none',
		image:'../../static/image/Warning.png',
		style:"z-index:9999"
		
	});
};
//确认框
export function showConfirm(msg, sureClick) {
	uni.showModal({
		title: '提示',
		content: msg,
		style:'z-index:99999',
		success: function(res) {
			if (res.confirm) {
				sureClick(true);
			} else if (res.cancel) {
				sureClick(false);
			}
		}
	});
}

//保留两位小数
export function setTwoFloat(num) {
	return Math.round(num * 100) / 100;
}
//处理日期 2020-1-1 ----> 2020-01-01
export function	splitdate(evt){
	if(evt == ""||evt==undefined){
		return
	}
	var str=evt; //这是一字符串
	var strarr= new Array(); //定义一数组
	strarr=str.split("-"); //以---号分割成数组
	//循环数组判断 月和日是否是个位数 如果是则在前面添加一个0
	for(var i =1;i<strarr.length;i++){
		// console.log(strarr[i].length);
		if(strarr[i].length<2){
		strarr[i] = ("0"+strarr[i]);
				}	
			}
		var newstr =strarr.join("-");//链接字符串
	return newstr;
}
